import 'package:bloc/bloc.dart';
import 'package:common/export/tools.dart';

import 'navigation_state.dart';

class NavigationCubit extends Cubit<NavigationState> {
  NavigationCubit() : super(NavigationState.initial()) {
    initTabs();
  }

  void onPageChanged(int index) {
    emit(state.copyWith(currentIndex: index));
    state.pageController?.jumpToPage(index);
  }

  void initTabs() {
    List<Map<String, dynamic>> tabs = [
      {
        "name": "首页",
        "icon": Clarity.home_line,
        "activeIcon": Clarity.home_solid,
      },
      {
        "name": "我的",
        "icon": Clarity.user_line,
        "activeIcon": Clarity.user_solid,
      },
    ];
    emit(state.copyWith(tabs: tabs));
  }
}
